package com.gourd.common.exception;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;

/**
 * @author gourd
 * @date 2018-11-23
 * 统一异常处理
 */
@Component
@Data
@NoArgsConstructor
public class ServiceException extends RuntimeException{

    private Integer status = INTERNAL_SERVER_ERROR.value();

    public ServiceException(String msg){
        super(msg);
    }

    public ServiceException(HttpStatus status, String msg){
        super(msg);
        this.status = status.value();
    }
}
